<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/backstage' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <el-button icon="el-icon-printer" @click="searchUser">生成电子综测表</el-button>
      <el-table :data="userList" border stripe :header-cell-style="{'text-align':'center'}"
                :cell-style="{'text-align':'center'}">
        <el-table-column label="学号" prop="id"></el-table-column>
        <el-table-column label="班级" prop="class_name"></el-table-column>
        <el-table-column label="姓名" prop="name"></el-table-column>
        <el-table-column label="自评分" prop="ownScore"></el-table-column>
        <el-table-column label="小组评分" prop="teamScore"></el-table-column>
        <el-table-column label="班级评分" prop="classScore"></el-table-column>
        <el-table-column label="学院评分" prop="collageScore"></el-table-column>
        <el-table-column label="复核分" prop="reCheck"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <div style="text-align: center">
<!--              <el-link type="primary" icon="el-icon-edit" size="mini" @click="showSubmitDialog(scope.row.uid)">评分</el-link>-->
              <el-link type="primary" icon="el-icon-user" size="mini" @click="showinfoDialog(scope.row.uid)"
                       :disabled="mine(scope.row)">查看信息
              </el-link>
              <el-link v-if="userInfo.userRole=='instructor'" type="primary" icon="el-icon-finished" size="mini" @click="reCheck(scope.row.id)">复核
              </el-link>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page="queryInfo.pageNum" :page-sizes="[5, 10, 20, 50]" :page-size="queryInfo.pageSize"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-card>

    <el-dialog title="学生信息" :visible.sync="infoDialogVisible" width="50%" @close="infoDialogClosed">
      <el-table :data="student" border stripe :header-cell-style="{'text-align':'center'}"
                :cell-style="{'text-align':'center'}">
        <el-table-column label="学号" prop="uid"></el-table-column>
        <el-table-column label="姓名" prop="name"></el-table-column>
        <el-table-column label="班级" prop="class"></el-table-column>
        <el-table-column label="学院" prop="collage"></el-table-column>
        <el-table-column label="状态" prop="state"></el-table-column>
      </el-table>
      <label1></label1>
      <div slot="footer" class="dialog-footer">
        <el-button @click="infoDialogClosed">取 消</el-button>
        <el-button type="primary" @click="infoDialogClosed">确 定</el-button>
      </div>
    </el-dialog>
<!--    <el-dialog :visible.sync = "submitDialogVisible" @close="submitDialogClosed">-->
<!--      -->
<!--    </el-dialog>-->
  </div>
</template>
<script>
import label1 from "../label/label";
import axios from "axios";

export default {
  name: 'State',
  components: {
    label1
  },
  created() {
    this.getUserList()
  },
  data() {
    return {
      queryInfo: {
        key: '',
        value: '',
        pageNum: 0,
        pageSize: 5,
      },
      session:this.$cookieStore.getCookie('session'),
      userInfo:{
        // userRole:this.$cookieStore.getCookie('userRole')
        userRole:'instructor'
      },
      value: [{
        value: 'username',
        label: '用户名'
      },
        {
          value: 'id',
          label: 'ID'
        }],
      userList: [{
        uid: '1912120399',
        class:'19软件工程3',
        name: '张三',
        ownScore: '100',
        teamScore: '100',
        classScore: '100',
        collageScore: '100',
        reCheck: '100'
      },{
        uid: '1912120399',
        class:'19软件工程3',
        name: '张三',
        ownScore: '100',
        teamScore: '100',
        classScore: '100',
        collageScore: '100',
        reCheck: '100'
      }],
      student: [{
        uid: '1912120399',
        name: '张三',
        class: '193',
        collage: '软件工程',
        state: '已完成'
      }],
      total: 0, //总记录数
      infoDialogVisible: false,
      submitDialogVisible: false,
      order_user_id: '',
      place: 'Manager',
      DialogTitle: '',
    }
  },
  methods: {
    async getUserList() {
      //获取学生列表
      let params ={
        session_key:this.session,
        student_id:''
      }
      const res = await axios.post('/api/api/api/searchStuForm',params)
      const {code,msg,data} = res.data
      if (code==200){
        this.userList=data
      }
    },
    async getStudent(id) {

      // this.student =
    },
    async reCheck(){

    },
    async searchUser() {


    },
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize
    },
    handleCurrentChange(newPage) {
      this.queryInfo.pageNum = newPage
    },
    async changeState(state) {

    },
    async changeUser(User) {

    },
    infoDialogClosed() {
      this.infoDialogVisible = false
    },
    submitDialogClosed(){
      this.submitDialogVisible = false
    },
    addUser() {

    },
    async delUser(id) {

    },
    async goSubmit(User) {
      this.$router.push('/backstage')
    },
    editUser() {

    },
    async showinfoDialog(id) {
      this.getStudent(id);
      this.infoDialogVisible = true
    },
    async showSubmitDialog() {

      this.submitDialogVisible = true
    },
    mine(User) {

    }

  },

}
</script>
<style scoped>
.el-breadcrumb {
  margin-bottom: 15px;
  font-size: 17px;
}

.btn_switch {
  text-align: center;
}

.operation {
  text-align: center;
}
</style>
